<?php include '../public/header.php' ?>
<?php include '../public/header_index.php' ?>
<style>
    #type_content{padding-top: 38px}
    #type_content button{width: 80%;margin-left: 10%!important;margin-top:10px;height: 35px;line-height: 29px;}
    #type_content .active{background-color:#2272eb;color: #FFFFFF}
    .usenum{padding-left: 10px;color: #409EFF;cursor: pointer;}
    .opt_a{margin-left: 5px;cursor: pointer;color: #65b5ff;font-size: 12px;}
</style>
<body class="laytp-container">
<div id="opt_nav">
</div>

<div class="layui-card" id="search-form">
    <div class="layui-card-body">
        <form class="layui-form" id="TableSearchFormId" lay-filter="TableSearchForm" onkeydown="keyTableSearch('TableSearchForm', 'datalist')">
            <div class="layui-form-item">
                <div class="layui-row">
                    <div class="layui-col-md3">
                        <label class="layui-form-label">案件编号</label>
                        <div class="layui-input-block">
                            <input type="text" name="number" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <label class="layui-form-label">案件名称</label>
                        <div class="layui-input-block">
                            <input type="text" name="name" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <label class="layui-form-label">案件类型：</label>
                        <div class="layui-input-block">
                            <select id="type" name="type" lay-filter="type">
                                <option value="">请选择</option>
                            </select>
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">案件年度</label>
                        <div class="layui-input-block">
                            <input type="text" name="year" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">案由</label>
                        <div class="layui-input-block">
                            <input type="text" name="cause" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">涉案单位</label>
                        <div class="layui-input-block">
                            <div id="she_unit" class="xmselect_div">
                                <div class="xmselect_title">请选择</div>
                            </div>
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">涉案项目</label>
                        <div class="layui-input-block">
                            <input type="text" name="engin" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <div class="layui-form-item search-div">
                            <div class="layui-form-item layui-inline">
                                <input type="hidden" id="fendt" name="fendt">
                                <button class="laytp-btn laytp-btn-md laytp-btn-primary" id="TableSearchButton" type="button"><i class="layui-icon layui-icon-search"></i>查询</button>
                                <button class="layui-btn layui-btn-primary" onclick="listTableReset()" id="TableSearchReset" type="reset" ><i class="layui-icon layui-icon-refresh"></i>重置</button>
                                <div id="search_open" onclick="toggle_search()">
                                    <i class="layui-icon layui-icon-down"></i>展开
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </form>
    </div>
</div>


<div class="layui-card" id="table-card">
    <div class="layui-card-body">
        <div class="layui-row">
            <div class="layui-col-md2" style="width: 150px!important;">
                <div id="type_content">
                    <button class="layui-btn layui-btn-primary active" key="1" type="button">7天内开庭</button>
                    <button class="layui-btn layui-btn-primary" key="2" type="button">30天内开庭</button>
                    <button class="layui-btn layui-btn-primary" key="3" type="button">本月开庭</button>
                </div>
            </div>
            <div class="layui-col-md10" id="table_list" style="width: calc(100% - 150px)!important;">
                <div class="layui-card-body">
                    <table id="datalist" lay-filter="datalist"></table>
                </div>
            </div>
        </div>
    </div>
</div>
<script type="text/html" id="test-dropdown-toolbar-barDemo">
    <div class="tab-list-authbut">
        <a href="javascript:;" class="bar_opt" onclick="auth_but_func_show('查看','{{d.LAY_TABLE_INDEX}}')">查看</a>
    </div>
</script>
<script type="text/html" id="toolbarDemo">
    <div class = "layui-btn-container">
    </div>
</script>
<script>

    var currButAuth, currTabData;
    layui.use(["laytp",'laypage','table','dropdown','form','soulTable'], function () {
        var laypage = layui.laypage, table = layui.table, dropdown = layui.dropdown, form = layui.form, soulTable = layui.soulTable;


        $("#type_content button").click(function () {
            $("#type_content button").removeClass('active');
            $(this).addClass('active');
            var fendt =  $(this).attr('key');
            $("#fendt").val(fendt)
            searchTableFunc(form, table)
        });

        $('#TableSearchReset').click(function () {
            $('.xmselect_div>xm-select').find('.xm-label-block').css('display','none');
            $('.xmselect_div').append('<div class="xmselect_title">请选择</div>');
            searchTableFunc(form, table)
        });

        setSouTableExport('近期开庭案件');
        table.render({
            elem: "#datalist",id: "datalist"
            ,url: facade.url(ask_legal_jin_list)
            ,where: {}
            , page: false, height: 'full-140'
            ,soulSort: TabInit.soulSort,method: TabInit.method, toolbar: TabInit.toolbar, overflow: TabInit.overflow
            ,defaultToolbar: TabInit.defaultToolbar,filter: TabInit.filter
            ,request: TabInit.request,response: TabInit.response
            ,contextmenu:get_table_contextmenu(soulTable)
            ,text: TabInit.text
            ,parseData: function (res) {
                currButAuth = res.data.butauth;
                tableButShow(currButAuth);


                var type_str = '<option value="">请选择</option>';
                var type = res.data.type;
                for (var key in type){
                    if(res.data.is_type == key){
                        type_str += '<option value="'+key+'" selected>'+type[key]+'</option>';
                    }else {
                        type_str += '<option value="'+key+'">'+type[key]+'</option>';
                    }

                }
                $("#type").html(type_str);

                xmselect_dan('she_unit', res.data.she_unit, res.data.is_she_unit, function (res) {
                    setTimeout(function () {
                        searchTableFunc(form, table);
                    },100)
                })

                render_from();
                return {
                    "code": res.code,
                    "msg": res.message,
                    "count": res.data.total,
                    "data": res.data.data
                };
            }
            , cols: [[
                {type: 'checkbox', fixed: 'left'}
                ,{type:'numbers',title:'序号',fixed:'left'}
                ,{field: 'kaitingdt', title: '开庭时间'}
                ,{field: 'number', title: '案件编号'}
                ,{field: 'name', title: '案件名称'}
                ,{field: 'type_name', title: '案件类型'}
                ,{field: 'year', title: '案件年度'}
                ,{field: 'cause', title: '案由'}
                ,{field: 'she_unit_name', title: '涉案单位'}
                ,{field: 'engin_name', title: '涉案项目'}
                ,{field: 'xianger', title: '项目负责人'}
                ,{field: 'xiangtel', title: '联系电话'}
                ,{field: 'gao_yuan', title: '原告'}
                ,{fixed: 'right', title:'操作', toolbar: '#test-dropdown-toolbar-barDemo',align:'center',width:200}
            ]]
            , done: function (res) {
                soulTable.render(this);

                currTabData = res.data;
                $.each(currTabData, function(index,item){
                    var chk = $('tr[data-index=' + item.LAY_TABLE_INDEX + '] .tab-list-authbut');
                    for (var key in currButAuth) {
                        if(currButAuth[key].pagetype === 0 || currButAuth[key].pagetype === 1){
                            chk.append(' <a ' +
                                'href="javascript:;" ' +
                                'class="bar_opt layui-hide" ' +
                                'lay-event="search" ' +
                                'data-butname="'+currButAuth[key].butname+'" ' +
                                'data-title="'+currButAuth[key].title+'" ' +
                                'onclick="auth_but_func_'+currButAuth[key].butname+'(\''+currButAuth[key].title+'\', '+index+')"' +
                                '>'+currButAuth[key].title+'' +
                                '</a>');
                        }
                    }
                });
                show_tab_but(currTabData);
            }
        });

        listTableSearch(form, table);

    });


    function auth_but_func_show(buttitle, index){
        var trData = currTabData[index];
        openPage('../legal/show.php?id='+trData.id);
    }
</script>
</body>
</html>
